import 'package:flutter/material.dart';
import 'package:zhongyiapp/pages/literature/literature_page.dart';
import 'package:zhongyiapp/pages/study/study_page.dart';
import 'package:zhongyiapp/pages/ai_diagnosis/ai_diagnosis_page.dart';
import 'package:zhongyiapp/pages/forum/forum_page.dart';
import 'package:zhongyiapp/pages/profile/profile_page.dart';

class MainPage extends StatefulWidget {
  const MainPage({Key? key}) : super(key: key);

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  int _currentIndex = 0;

  final List<Widget> _pages = [
    const LiteraturePage(),
    const StudyPage(),
    const AiDiagnosisPage(),
    const ForumPage(),
    const ProfilePage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        type: BottomNavigationBarType.fixed,
        selectedItemColor: const Color(0xFFBFA47C),
        unselectedItemColor: Colors.grey,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.book),
            label: '文献',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.school),
            label: '学习',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.medical_services),
            label: 'AI问诊',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.forum),
            label: '论坛',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: '我的',
          ),
        ],
      ),
    );
  }
}
